package com.yq.practice.design.iterator;

import java.util.Iterator;

/**
 * @ClassName InfoCollege
 * @Description TODO
 * @Author yaoqiang
 * @Date 2021/8/25 19:53
 * @Version 1.0
 */
public class InfoCollege implements College {
    Department[] departments;
    int index=0;

    public InfoCollege() {
        departments=new Department[5]; addDepartment("java","java");addDepartment("php","php");
    }

    public InfoCollege(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public Iterator createIterator() {
        return  new InfoIterator(departments);
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department=new Department(name,desc);
        departments[index]=department;
        index+=1;
    }
}
